﻿-var schedule = ViewData["Schedule"] as Schedule
-var date = (DateTime)ViewData["Date"]
-int days = DateTime.DaysInMonth(date.Year,date.Month)
-var firstday = (DateTime)ViewData["Firstday"]
-int rows = (int)ViewData["Rows"]
#schedulenav
  %table{width="100%"}
    %tr
      %td{width="10%"}
        %a.dashed{href="#",onclick=string.Format("return setDate('{0}')",date.AddYears(-1).ToDateString())}="&larr;&nbsp;"+(date.Year-1)
      %td{width="10%"}
        %a.dashed{href="#",onclick=string.Format("return setDate('{0}')",date.AddMonths(-1).ToDateString())}="&larr;&nbsp;"+date.AddMonths(-1).ToString("MMMM")
      %td.center{width="10%"}
        %a.dashed{href="#",onclick=string.Format("return setDate('{0}')",DateTime.Now.ToDateString())}="Сегодня"
      %td.center{width="50%"}
        %h2=date.ToString("MMMM yyyy")
      %td.right{width="10%"}
        %a.dashed{href="#",onclick=string.Format("return setDate('{0}')",date.AddMonths(+1).ToDateString())}=date.AddMonths(+1).ToString("MMMM")+"&rarr;&nbsp;"
      %td.right{width="10%"}
        %a.dashed{href="#",onclick=string.Format("return setDate('{0}')",date.AddYears(+1).ToDateString())}=(date.Year+1)+"&rarr;&nbsp;"
#scheduletable
  #nextmonth
  #prevmonth
  %table.scheduleheader.data
    %tr
      %th.noborder{width="30"}
      %th{width="14%"} Пн.
      %th{width="14%"} Вт.
      %th{width="14%"} Ср.
      %th{width="14%"} Чт.
      %th{width="14%"} Пт.
      %th{width="14%"} Сб.
      %th{width="14%"} Вс.
      %th.noborder{width="30"}
  %table.schedule
    -for(int i=0;i<rows;i++)
      %tr
        -if(i==0)
          %td.prevmonth{rowspan=rows,onclick=string.Format("return setDate('{0}')",date.AddMonths(-1).ToDateString())}
            %img{src="img/prev.gif"}
        -for(int d=0;d<7;d++)
          -var cdate = firstday.AddDays(i*7+d)
          -IWorkingHours wh = null
          -if(schedule!=null)
            -wh = schedule.GetWorkingHours(cdate)
          -string cls = (schedule!=null?" pointer":"") + (wh==null ? "" : " hasschedule " + (wh.TimeStart.HasValue ? " workingday":" vacation"))
          %td{width="14%",class=cls,onclick=string.Format("showDayDetails(this,'{0}')",cdate.ToDateString())}
            %div{class=(wh!=null) ? (wh.Type==WorkingHoursType.Period?"stperiod":"stexception") : "stnoschedule"}
              %span.sday=cdate.ToString("dd")
              %span.smonth=cdate.ToString("MMM")
            -if(wh != null && wh.TimeStart.HasValue)
              .wt
                =string.Format("<nobr>{0}&ndash;{1}</nobr> Работа",wh.TimeStart.Value.ToTimeString(),wh.TimeEnd.Value.ToTimeString())
              -if(wh.BreakStart.HasValue)
                .wt
                  =string.Format("<nobr>{0}&ndash;{1}</nobr> Перерыв",wh.BreakStart.Value.ToTimeString(),wh.BreakEnd.Value.ToTimeString())
        -if(i==0)
          %td.nextmonth{rowspan=rows,onclick=string.Format("return setDate('{0}')",date.AddMonths(1).ToDateString())}
            %img{src="img/next.gif"}